package com.acidu.tags.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.acidu.tags.domain.AciduTag;
import com.acidu.tags.service.IAciduTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签管理Controller
 * 
 * @author xiaofeng
 * @date 2025-01-22
 */
@RestController
@RequestMapping("/acidu-blogs/tags")
public class AciduTagController extends BaseController
{
    @Autowired
    private IAciduTagService aciduTagService;

    /**
     * 查询标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('acidu-blogs:tags:list')")
    @GetMapping("/list")
    public TableDataInfo list(AciduTag aciduTag)
    {
        startPage();
        List<AciduTag> list = aciduTagService.selectAciduTagList(aciduTag);
        return getDataTable(list);
    }

    /**
     * 导出标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('acidu-blogs:tags:export')")
    @Log(title = "标签管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AciduTag aciduTag)
    {
        List<AciduTag> list = aciduTagService.selectAciduTagList(aciduTag);
        ExcelUtil<AciduTag> util = new ExcelUtil<AciduTag>(AciduTag.class);
        util.exportExcel(response, list, "标签管理数据");
    }

    /**
     * 获取标签管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('acidu-blogs:tags:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aciduTagService.selectAciduTagById(id));
    }

    /**
     * 新增标签管理
     */
    @PreAuthorize("@ss.hasPermi('acidu-blogs:tags:add')")
    @Log(title = "标签管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AciduTag aciduTag)
    {
        return toAjax(aciduTagService.insertAciduTag(aciduTag));
    }

    /**
     * 修改标签管理
     */
    @PreAuthorize("@ss.hasPermi('acidu-blogs:tags:edit')")
    @Log(title = "标签管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AciduTag aciduTag)
    {
        return toAjax(aciduTagService.updateAciduTag(aciduTag));
    }

    /**
     * 删除标签管理
     */
    @PreAuthorize("@ss.hasPermi('acidu-blogs:tags:remove')")
    @Log(title = "标签管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aciduTagService.deleteAciduTagByIds(ids));
    }
}
